{extend name="public:_index" /}
{block name="title"}编辑文章{/block}
{block name="description"}描述{/block}
{block name="keywords"}关键词{/block}
{block name="heading"}文章{/block}
{block name="breadcrumb"}文章 > 编辑{/block}
{block name="wrapper"}

<!-- Plugin stylesheets -->
<link href="/static/back/plugins/misc/qtip/jquery.qtip.css" rel="stylesheet" type="text/css" />
<link href="/static/back/plugins/forms/inputlimiter/jquery.inputlimiter.css" type="text/css" rel="stylesheet" />
<link href="/static/back/plugins/forms/togglebutton/toggle-buttons.css" type="text/css" rel="stylesheet" />
<link href="/static/back/plugins/forms/uniform/uniform.default.css" type="text/css" rel="stylesheet" />
<link href="/static/back/plugins/forms/color-picker/color-picker.css" type="text/css" rel="stylesheet" />
<link href="/static/back/plugins/forms/select/select2.css" type="text/css" rel="stylesheet" />
<link href="/static/back/plugins/forms/validate/validate.css" type="text/css" rel="stylesheet" />
<link href="/static/back/plugins/editormd/css/editormd.min.css" type="text/css" rel="stylesheet" />

<form action="javascript:void(0);" class="form-horizontal" id="form-article-edit" data-action="{:url('back/Article/editProcess')}" data-id="{$article.id}">
    <div class="form-group">
        <div class=" col-lg-2">
            <button class="btn btn-info button_submit" type="submit" name="status" value="publish">立即发布</button>
            <button class="btn btn-white button_submit" type="submit" name="status" value="save">保存</button>
        </div>
    </div>
    <ul id="myTab" class="nav nav-tabs pattern">
        <li class="active"><a href="#article" data-toggle="tab">article</a></li>
        <li class=""><a href="#seo" data-toggle="tab">seo</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane fade active in" id="article">
            <div class="form-group">
                <label class="col-lg-1 control-label" for="form-title">标题</label>
                <div class="col-lg-6">
                    <input type="text" name="title" class="form-control uniform-input text" id="form-title" value="{$article.title}">
                </div>
            </div>

            <div class="form-group">
                <label class="col-lg-1 control-label" for="form-keywords">关键词</label>
                <div class="col-lg-6">
                    <input type="text" name="keywords" class="form-control uniform-input text" id="form-keywords" value="{$article.keywords}">
                </div>
            </div>

            <div class="form-group">
                <label class="col-lg-1 control-label" for="form-category_id">分类</label>
                <div class="col-lg-6">
                    <select name="category_id" id="form-category_id">
                        <option value="0">未分类</option>
                        {volist name="categories" id="vo"}
                        <option value="{$vo.id}"
                            {eq name="vo.id" value="$article.categories[0]['category']['id']"}
                             selected
                            {else/}
                            ''
                            {/eq}
                        >{$vo._name}</option>
                        {/volist}
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-lg-1 control-label" for="form-summary">简介</label>
                <div class="col-lg-9">
                    <textarea id="form-summary" name="summary" class="form-control" placeholder="请输入文章简介" style="height:100px;">{$article.summary}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-1 control-label">标签</label>
                <div class="col-lg-9">
                    <input type="text" class="form-control" name="tag[new]" placeholder="多个标签英文逗号,号隔开">
                    <div class="col-sm-12  checkbox i-checks">
                        {volist name="tags" id="tag"}
                        <label class="checkbox-inline col-sm-2" style="margin-left: 0;">
                            <input type="checkbox" name="tag[]" value="{$tag['id']}" id="inlineCheckbox1"
                               {volist name="article.tags" id="v"}
                                   {eq name="tag.id" value="$v['tag']['id']"}
                                    checked
                                   {else/}
                                   ''
                                   {/eq}
                               {/volist}
                            >{$tag.name}
                        </label>
                        {/volist}
                    </div>
                </div>
            </div>

        </div>
        <div class="tab-pane fade" id="seo">

            <div class="form-group">
                <label class="col-lg-1 control-label" for="form-meta_title">SEO标题</label>
                <div class="col-lg-6">
                    <input type="text" name="meta_title" class="form-control uniform-input text" id="form-meta_title">
                </div>
            </div>

            <div class="form-group">
                <label class="col-lg-1 control-label" for="form-meta_keywords">SEO关键词</label>
                <div class="col-lg-6">
                    <input type="text" name="meta_keywords" class="form-control uniform-input text" id="form-meta_keywords">
                </div>
            </div>

            <div class="form-group">
                <label class="col-lg-1 control-label" for="form-meta_description">SEO描述</label>
                <div class="col-lg-9">
                    <textarea id="form-meta_description" name="meta_description" class="form-control" placeholder="请输入SEO描述" style="height:100px;"></textarea>
                </div>
            </div>

        </div>
    </div>
    <br>

</form>
<div class="form-group" >
    <label class="col-lg-1 control-label" for="form-content">文章内容</label>
    <div class="col-lg-12">
        <div id="editormd-article" class="editormd" >
            <textarea class="editormd-markdown-textarea" name="content" id="form-content">{$article.content}</textarea>
            <textarea class="editormd-html-textarea"></textarea>
        </div>
    </div>
</div>
{/block}

{block name="plugins_js"}

<!-- Form plugins -->

<script type="text/javascript" src="/static/back/plugins/forms/elastic/jquery.elastic.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/inputlimiter/jquery.inputlimiter.1.3.min.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/maskedinput/jquery.maskedinput-1.3.min.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/togglebutton/jquery.toggle.buttons.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/uniform/jquery.uniform.min.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/globalize/globalize.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/color-picker/colorpicker.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/timeentry/jquery.timeentry.min.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/select/select2.min.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/dualselect/jquery.dualListBox-1.3.min.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/tiny_mce/tinymce.min.js"></script>
<script type="text/javascript" src="/static/back/js/supr-theme/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="/static/back/js/supr-theme/jquery-ui-sliderAccess.js"></script>
<script type="text/javascript" src="/static/back/plugins/editormd/editormd.min.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/validate/jquery.validate.js"></script>
<script type="text/javascript" src="/static/back/plugins/forms/wizard/jquery.form.js"></script>

<!-- Init plugins -->

<script type="text/javascript" src="/static/back/js/forms.js"></script><!-- Init plugins only for page -->

<script type="text/javascript" src="/static/back/js/common.js"></script>
<script type="text/javascript" src="/static/back/plugins/layer/layer.js"></script>

<script type="text/javascript">
    // editormd
    $(function() {
        editormd('editormd-article',{
            width:"100%",
            height:640,
            // theme:'dark',
            // previewTheme:'dark',
            // editorTheme:'pastel-on-dark',
            syncScrolling:"single",
            path:"/static/back/plugins/editormd/lib/",
            emoji:true,
            saveHTMLToTextarea:true,
            imageUpload:true,
            imageFormats:['jpg','jpeg', 'png'],
            imageUploadURL:'/admin/article/markdown_image',
        });
    });
</script>
<script>
    $("#form-article-edit").validate({
        rules:{
            title: {
                required: true,
                minlength: 2
            }
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            $(form).ajaxSubmit({
                type:'post',
                url: $(form).data('action'),
                dataType: 'json',
                data:{
                    "id": $(form).data('id'),
                    "content": $("textarea[name='content']").val(),
                    "html_content": $("textarea[name='editormd-article-html-code']").val()
                },
                success:function(response){
                    if (response.status == 'success') {
                        layer.confirm('保存成功', {
                            icon:1,
                            btn: ['继续编辑','文章列表'] //按钮
                        }, function(){
                            location.reload();
                        }, function(){
                            location.href='/admin/article/index.html';
                        });
                    } else if (response.status == 'failed') {
                        layer.msg('添加失败',{icon:2,time:1000});
                    }
                },error:function(data) {
                    layer.msg('必填参数不能为空', {icon:2,time:1000});
                }
             });
        }
    });
</script>


{/block}



